@extends('layouts.app')

@section('content')
        <div class="header">
            <ul class="breadcrumb">
                <li><i class="fa fa-fw fa-cog"></i>用户管理</li>
                <li class="active"><a href="">用户列表</a> </li>
            </ul>
        </div>
        <div class="main-content">
            <div class="btn-toolbar list-toolbar">
                <a href="{{url('admin/user/add')}}" class="easyui-linkbutton" iconCls="icon-add">添加</a>
                <div class="form-all">
                    <table class="table table-form table-striped table-bordered table-condensed">
                        <thead>
                        <tr>
                            <th width="80">序号</th>
                            <th>用户名</th>
                            <th>姓名</th>
                            <th>权限组</th>
                            <th>管辖区域（警员用户）</th>
                            <th>所属区域（企业用户）</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        @foreach ($res as $key=>$re)
                            <tr>
                                <td>{{ $key+1 }}</td>
                                <td>{{ $re->email }}</td>
                                <td>{{ $re->name }}</td>
                                <td>@if($re->id == 1)超级管理员@else{{ getValue($re->role_id,'roles','id','name') }}@endif</td>
                                <td>@if($re->role_id != 22){{ getValue($re->city,'area','id','name') }}{{ getValue($re->area,'area','id','name') }}{{ getValue($re->org_id,'area','id','name') }}@endif</td>
                                <td>@if($re->role_id == 22){{ getValue($re->city,'area','id','name') }}{{ getValue($re->area,'area','id','name') }}{{ getValue($re->org_id,'area','id','name') }}@endif</td>
                                <td>
                                    <a href="{{url('admin/user/edit',$re->id)}}" class="easyui-linkbutton" iconCls="icon-edit" plain="true">编辑</a>
                                    <a href="{{url('admin/user/edit_area',$re->id)}}" class="easyui-linkbutton" iconCls="icon-edit" plain="true">管辖区域设置</a>
                                    <a href="{{url('admin/user/del',$re->id)}}" class="easyui-linkbutton del" iconCls="icon-cancel" plain="true">删除</a>
                                </td>
                            </tr>
                        @endforeach
                        </tbody>
                    </table>
                </div>
                <span>共{{$count}}条数据</span>
                <ul class="pagination pull-right">
                    {{ $res->render() }}
                </ul>
            </div>
        </div>

    <script type="text/javascript">
        function check() {
            $('#search_form').submit();
        }

        $('.del').click(function(){
            var i=window.confirm("确认删除该条数据？");
            if(i==0){
                return false;
            }
        });
    </script>
        <script>
            $(document).ready(function(){
                var winHeight =  window.screen.height;
                var winWidth = 	window.screen.width;
                if(winWidth == 1024){
                    $('#taby').css('height',465+'px');
                    $('#taby').find('iframe').css('height',436+'px');
                }else if(winWidth == 1280){
                    $('#taby').css('height',465+'px');
                    $('#taby').find('iframe').css('height',436+'px');
                }else if(winWidth == 1366){
                    $('#taby').css('height',465+'px'); $('#taby').find('iframe').css('min-height',436+'px');
                }else if(winWidth == 1920){
                    $('#taby').css('height',625+'px');
                    $('#taby').find('iframe').css('min-height',596+'px');
                }else{
                    $('#taby').css('height',465+'px');
                    $('#taby').find('iframe').css('min-height',436+'px');
                }
            })

            function load_city_data_from_menu($id){
                $('#dg').datagrid('load',{
                    city: $id,
                });
                $("input[name='city']").val($id);
                $("input[name='area']").val('');
                $("input[name='org_id']").val('');
            }

            function load_area_data_from_menu($id){
                $('#dg').datagrid('load',{
                    area: $id,
                });
                $("input[name='city']").val('');
                $("input[name='area']").val($id);
                $("input[name='org_id']").val('');
            }
            function load_org_data_from_menu($id){
                $('#dg').datagrid('load',{
                    org_id: $id,
                });
                $("input[name='city']").val('');
                $("input[name='area']").val('');
                $("input[name='org_id']").val($id);
            }
        </script>
@stop

